Repository navigation
mactrack: fail the rebuild when the drained source cannot be dropped - #424
Merged
Merged
Conversation
Copilot third pass: if DROP TABLE on the drained mac_track_aggregated_ports_upgrade failed, the rebuild still set mt_aggregated_ports_rebuilt=on and returned success. The leftover table then kept the poller paused and the web hook launching, but every retry took the rebuilt-flag early return and never attempted the drop again. Check the DROP result and return false before recording completion so cleanup stays retryable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change that keeps aggregated-ports cleanup retryable after a failed table drop.
No open issues 🎉
What changed in this PR
Keeps cleanup retryable in MacTrack’s background database upgrade when dropping the drained aggregated-ports source table fails.
Changes:
- Logs the failed drop and returns
falsebefore setting the rebuild completion flag. - Adds a regression test confirming that drop failure reports failure and leaves completion unset.
| File | Description |
|---|---|
tests/Unit/AggregatedPortsRebuildTest.php |
Tests failure handling when the drained source cannot be dropped. |
includes/database.php |
Checks the drop result before marking the rebuild complete. |
Review effort: Balanced
xmacan
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Follow-up to #423 (merged). The Copilot review of #423 posted one more comment after it was merged: if the aggregated-ports rebuild's final
DROP TABLEon the drained work table failed, the rebuild still setmt_aggregated_ports_rebuilt = onand reported success.That left a stuck state: the leftover
mac_track_aggregated_ports_upgradetable keeps the poller paused and the web hook launching upgrades, but every retry takes the rebuilt-flag early return and never attempts the drop again.Fix
mactrack_rebuild_aggregated_ports()now checks theDROP TABLE IF EXISTSresult and returnsfalse(logging) before setting the completion flag. The flag stays off, so the next relaunch runs the full path again — the source is already drained, so it goes straight to the COUNT guard and retries the drop — instead of taking the early return. Cleanup stays retryable.Testing
AggregatedPortsRebuildTestaddstestRebuildRetriesWhenDroppingTheDrainedSourceFails).